package com.css.fxfzaqbz.modules.data.service.impl;

import com.css.fxfzaqbz.constants.YNEnum;
import com.css.fxfzaqbz.modules.assess.entity.EarthEntity;
import com.css.fxfzaqbz.modules.data.entity.BigDisposeManager;
import com.css.fxfzaqbz.modules.data.entity.ImportantActivity;
import com.css.fxfzaqbz.modules.data.repository.BigDisposeManagerRepository;
import com.css.fxfzaqbz.modules.data.service.BigDisposeManagerService;
import com.css.fxfzaqbz.util.PlatformDateUtils;
import com.css.fxfzaqbz.util.PlatformSessionUtils;
import com.css.fxfzaqbz.util.UUIDGenerator;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class BigDisposeManagerServiceImpl implements BigDisposeManagerService {
    @Resource
    BigDisposeManagerRepository bigDisposeManagerRepository;
    @Override
    public void saveTask(ImportantActivity importantActivity1) {
        String a="处置要点分析";
        BigDisposeManager bigDisposeManager = bigDisposeManagerRepository.getTask(importantActivity1.getIaId(),a);
        if (bigDisposeManager == null) {
            BigDisposeManager bigDisposeManager1 = new BigDisposeManager();
            bigDisposeManager1.setId(UUIDGenerator.getUUID());
            bigDisposeManager1.setTaskName("处置要点分析");
            bigDisposeManager1.setIaStatus(YNEnum.N.toString());
            bigDisposeManager1.setIaId(importantActivity1.getIaId());
            bigDisposeManager1.setDelFlag(YNEnum.N.toString());
            bigDisposeManager1.setCreateTime(PlatformDateUtils.getCurrentTimestamp());
            bigDisposeManager1.setCreateUser(PlatformSessionUtils.getUserId());
            bigDisposeManager1.setIaOpinion(importantActivity1.getIaOpinion());
            bigDisposeManagerRepository.saveTask(bigDisposeManager1);
        }
        String b="辅助分析";
        BigDisposeManager bigDisposeManager2 = bigDisposeManagerRepository.getTask(importantActivity1.getIaId(),b);
        if (bigDisposeManager2 == null) {
            BigDisposeManager bigDisposeManager1 = new BigDisposeManager();
            bigDisposeManager1.setId(UUIDGenerator.getUUID());
            bigDisposeManager1.setTaskName("辅助分析");
            bigDisposeManager1.setIaStatus(YNEnum.N.toString());
            bigDisposeManager1.setIaId(importantActivity1.getIaId());
            bigDisposeManager1.setDelFlag(YNEnum.N.toString());
            bigDisposeManager1.setCreateTime(PlatformDateUtils.getCurrentTimestamp());
            bigDisposeManager1.setCreateUser(PlatformSessionUtils.getUserId());
            bigDisposeManager1.setIaOpinion(importantActivity1.getIaOpinion());
            bigDisposeManagerRepository.saveTask(bigDisposeManager1);
        }

        String c="次生灾害隐患评估";
        BigDisposeManager bigDisposeManager3 = bigDisposeManagerRepository.getTask(importantActivity1.getIaId(),c);
        if (bigDisposeManager3 == null) {
            BigDisposeManager bigDisposeManager1 = new BigDisposeManager();
            bigDisposeManager1.setId(UUIDGenerator.getUUID());
            bigDisposeManager1.setTaskName("次生灾害隐患评估");
            bigDisposeManager1.setIaStatus(YNEnum.N.toString());
            bigDisposeManager1.setIaId(importantActivity1.getIaId());
            bigDisposeManager1.setDelFlag(YNEnum.N.toString());
            bigDisposeManager1.setCreateTime(PlatformDateUtils.getCurrentTimestamp());
            bigDisposeManager1.setCreateUser(PlatformSessionUtils.getUserId());
            bigDisposeManager1.setIaOpinion(importantActivity1.getIaOpinion());
            bigDisposeManagerRepository.saveTask(bigDisposeManager1);
        }
    }

    @Override
    public void upStatus(String id) {
        bigDisposeManagerRepository.upStatus(id);
    }
}
